package hczc.longcai.com.hccrowdfunding.home.fourth_mine.activities;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import hczc.longcai.com.hccrowdfunding.R;
import hczc.longcai.com.hccrowdfunding.activity.BaseActivity;
import hczc.longcai.com.hccrowdfunding.home.fourth_mine.adapters.FAQAdapter;
import hczc.longcai.com.hccrowdfunding.home.fourth_mine.beans.FAQ;

public class FAQActivity extends BaseActivity implements View.OnClickListener, AdapterView.OnItemClickListener {

    private static int STATE_TITLE = 0;
    private static int STATE_DETAILS = 1;
    private int state = 0;

    private List<FAQ> list;
    private ListView listView;
    private FAQAdapter adapter;
    private LinearLayout titles;
    private LinearLayout details;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_faq);

        initDatas();
        initViews();
    }

    private void initDatas() {
        list = new ArrayList<>();
        list.add(new FAQ("常见问题1","123"));
        list.add(new FAQ("常见问题2","123"));
        list.add(new FAQ("常见问题3","123"));
    }

    private void initViews() {
        findViewById(R.id.head_back).setOnClickListener(this);
        ((TextView) findViewById(R.id.head_title)).setText("常见问题");
        listView = ((ListView) findViewById(R.id.mine_setting_faq_listview));
        titles = ((LinearLayout) findViewById(R.id.mine_faq_titles));
        details = ((LinearLayout) findViewById(R.id.mine_faq_details));
        adapter = new FAQAdapter(this,list);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(this);

    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        switch (id){
            case R.id.head_back:
                if(state == STATE_DETAILS){
                    listView.setVisibility(View.VISIBLE);
                    details.setVisibility(View.GONE);
                    state = STATE_TITLE;
                }else {
                    finish();
                }
                break;
        }
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        listView.setVisibility(View.GONE);
        details.setVisibility(View.VISIBLE);
        state = STATE_DETAILS;
    }



}
